package com.alibaba.sample.kantiezi.dal.dataobject;

import java.io.Serializable;

import java.util.Calendar;
import java.util.Date;

public class Account
        implements Serializable {
    private static final long serialVersionUID = 223699892101651012L;
    private User              user;
    private String            email;
    private String            firstName;
    private String            lastName;
    private String            status;
    private String            address1;
    private String            address2;
    private String            city;
    private String            state;
    private String            zip;
    private String            country;
    private String            phone;
    private String            creditCardNumber;
    private String            creditCardType;
    private Date              creditCardExpiry;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getAddress1() {
        return address1;
    }

    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }

    public Date getCreditCardExpiry() {
        return creditCardExpiry;
    }

    public void setCreditCardExpiry(Date creditCardExpiry) {
        this.creditCardExpiry = creditCardExpiry;
    }

    public int getCreditCardExpiryMonth() {
        Calendar calendar = Calendar.getInstance();

        if (creditCardExpiry != null) {
            calendar.setTime(creditCardExpiry);
        }

        return calendar.get(Calendar.MONTH) + 1;
    }

    public void setCreditCardExpiryMonth(int month) {
        Calendar calendar = Calendar.getInstance();

        if (creditCardExpiry != null) {
            calendar.setTime(creditCardExpiry);
        }

        int year = calendar.get(Calendar.YEAR);

        calendar.clear();
        calendar.set(Calendar.MONTH, month - 1);
        calendar.set(Calendar.YEAR, year);
    }

    public int getCreditCardExpiryYear() {
        Calendar calendar = Calendar.getInstance();

        if (creditCardExpiry != null) {
            calendar.setTime(creditCardExpiry);
        }

        return calendar.get(Calendar.YEAR);
    }

    public void setCreditCardExpiryYear(int year) {
        Calendar calendar = Calendar.getInstance();

        if (creditCardExpiry != null) {
            calendar.setTime(creditCardExpiry);
        }

        int month = calendar.get(Calendar.MONTH);

        calendar.clear();
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.YEAR, year);
    }

    public String getCreditCardNumber() {
        return creditCardNumber;
    }

    public void setCreditCardNumber(String creditCardNumber) {
        this.creditCardNumber = creditCardNumber;
    }

    public String getCreditCardType() {
        return creditCardType;
    }

    public void setCreditCardType(String creditCardType) {
        this.creditCardType = creditCardType;
    }
}
